package 异或运算的骚操作;

/**
 * @author ljb
 * @version 1.0
 * @Date 2024/11/30
 */
// 找到缺失的数字
// 测试链接 : https://leetcode.cn/problems/missing-number/
public class Code03_MissingNumber {

    public int missingNumber(int[] nums) {
        int eorAll = 0, eorHas = 0;
        for(int i = 0; i < nums.length; i++){
            eorAll = eorAll ^ i;
            eorHas = eorHas ^ nums[i];
        }
        eorAll = eorAll ^ nums.length;
        return eorAll ^ eorHas;

    }
}
